Ensure manifest paths are absolute paths
authorAlex Crichton <alex@alexcrichton.com>
Fri, 1 Aug 2014 15:52:51 +0000 (08:52 -0700)
committerAlex Crichton <alex@alexcrichton.com>
Fri, 1 Aug 2014 15:52:51 +0000 (08:52 -0700)
Closes #299

src/cargo/util/important_paths.rs
tests/test_cargo_compile.rs

index 614bfd307674baffb15bec7ffbdbfac5c228e181..b7604d51c53a63b53f571f7eaf8b741cadbb68b9 100644 (file)
@@ -1,4 +1,4 @@
-use std::os::{getcwd};
+use std::os;
 use util::{CargoResult, CliError, CliResult, human};
 
 /// Iteratively search for `file` in `pwd` and its parents, returning
@@ -34,12 +34,12 @@ pub fn find_project_manifest(pwd: &Path, file: &str) -> CargoResult<Path> {
 pub fn find_root_manifest_for_cwd(manifest_path: Option<String>) -> CliResult<Path> {
     match manifest_path {
         Some(path) => Ok(Path::new(path)),
-        None => match find_project_manifest(&getcwd(), "Cargo.toml") {
-                    Ok(x) => Ok(x),
-                    Err(_) => Err(CliError::new("Could not find Cargo.toml in this \
-                                                 directory or any parent directory", 102))
-                }
-    }
+        None => match find_project_manifest(&os::getcwd(), "Cargo.toml") {
+            Ok(x) => Ok(x),
+            Err(_) => Err(CliError::new("Could not find Cargo.toml in this \
+                                         directory or any parent directory", 102))
+        }
+    }.map(|path| os::make_absolute(&path))
 }
 
 /// Return the path to the `file` in `pwd`, if it exists.
index 49e45b96f008d051bf78133dce89eaff59f75880..b5bf1173a075aefb22035bdc7d54b73d6f726007 100644 (file)
@@ -25,6 +25,18 @@ test!(cargo_compile_simple {
       execs().with_stdout("i am foo\n"));
 })
 
+test!(cargo_compile_manifest_path {
+    let p = project("foo")
+        .file("Cargo.toml", basic_bin_manifest("foo").as_slice())
+        .file("src/foo.rs", main_file(r#""i am foo""#, []).as_slice());
+
+    assert_that(p.cargo_process("cargo-build")
+                 .arg("--manifest-path").arg("foo/Cargo.toml")
+                 .cwd(p.root().dir_path()),
+                execs().with_status(0));
+    assert_that(&p.bin("foo"), existing_file());
+})
+
 test!(cargo_compile_with_invalid_manifest {
     let p = project("foo")
         .file("Cargo.toml", "");